package svl.videoplayer 
{
	import flash.net.NetStream;	
	
	import svl.videoplayer.state.IState;
	import svl.videoplayer.state.PauseState;
	import svl.videoplayer.state.PlayState;
	import svl.videoplayer.state.StopState;		

	/**
	 * @author sanderl
	 */
	public class VideoStateManager 
	{
		private var stopState:IState;
		private var playState:IState;
		private var pauseState:IState;
		private var state:IState;
		
		private var ns:NetStream;
		private var flv:String;
		
		public function VideoStateManager(ns:NetStream, flv:String)
		{
			playState = new PlayState(this);
			stopState = new StopState(this);
			pauseState = new PauseState(this);
			state = stopState;
			
			this.ns = ns;
			this.flv = flv;
		}
		
		public function startPlay():void
		{
			state.startPlay(ns, flv);
		}
		
		public function stopPlay():void
		{
			state.stopPlay(ns);
		}
		
		public function doPause():void
		{
			state.doPause(ns);
		}
		
		public function setState(value:IState):void
		{
			trace(">New state set" + value);
			this.state = value;
		}
		
		public function getState():IState
		{
			return this.state;
		}
		
		public function getPlayState():IState
		{
			return this.playState;
		}
		
		public function getStopState():IState
		{
			return this.stopState;
		}
		
		public function getPauseState():IState
		{
			return this.pauseState;
		}
	}
}
